function [P Pi c] = AIS_fixedpoint_hat_nonetwork(X,tauhat,t)

% Ouput: Price indices P and Pi
% Pi is Pi_hat^-theta, P is P_hat^-theta


Y = sum(X,2);
E = sum(X,1)';
YW = sum(Y);
N = length(Y);

Pi = ones(N,1);
P = ones(N,1);
lim = 1e-6;
c = 0; diff=1;

% Pi is Pi_hat^-theta, P is P_hat^-theta
while diff>lim
  
  xx = Pi.^(1/(t+1))./P;  
  Pinew = sum(X./repmat(Y,1,N).*tauhat.^(-t).*repmat(xx',N,1),2);
  
  k = 1;
  Yhatnew = Pinew.^(1/(t+1));
  Pinew = Pinew/(sum((Y/YW).*Yhatnew)/k).^(t+1);       %     

  xx = Pinew.^(1/(t+1))./Pinew;
  Pnew = sum(X./repmat(E',N,1).*tauhat.^(-t).*repmat(xx,1,N),1)';    
  
  x = Pnew-P;
  
  diff = x'*x;
  Pi = Pinew; 
  P = Pnew;
  c = c+1;
  if c>5000 break; end;
end
disp('Converged. Counter:'); disp(c); disp(diff);
